package axdoc.rule.check;

import com.alibaba.fastjson.JSONObject;

public class RangeCheck extends AbsCheck {

	public String pattern;

	public int value;

	public String getPattern() {
		return pattern;
	}

	public void setPattern(String pattern) {
		this.pattern = pattern;
	}

	public int getValue() {
		return value;
	}

	public void setValue(int value) {
		this.value = value;
	}

	@Override
	public boolean check(JSONObject obj) {
		return false;
	}

	public boolean compareNum(String pattern, int num, int compare) {
		if (compare < 0) {
			return true;
		}
		boolean flag = false;
		String patterned = pattern.replace("1", ">").replace("2", "<").replace("3", "=").replace(",", "");
		switch (patterned) {
		case ">":
			flag = (num > compare);
			break;
		case "<":
			flag = (num < compare);
			break;
		case "=":
			flag = (compare == num);
			break;
		case ">=":
		case "=>":
			flag = (num >= compare);
			break;
		case "<=":
		case "=<":
			flag = (num <= compare);
			break;
		case "><":
		case "<>":
			flag = (compare != num);
			break;
		default:
			break;
		}
		return flag;
	}

}
